'''
Created on Mar 21, 2012

@author: Vu Dao
'''


from xlrd import open_workbook
from selenium import webdriver


book = open_workbook('../Database/data.xls')
sheet0=book.sheet_by_index(0)

#def preCondition(self):
#    self.verificationErrors = []
#    self.selenium = selenium("localhost", 4444, "*firefox","http://www.google.com/")
#    self.selenium.start()
#    
#def endCondition(self):
#    self.selenium.stop()
#    self.assertEqual([], self.verificationErrors)

def preCondition(self):
    self.browser = webdriver.Firefox()
    self.browser.get("http://localhost/index.php")
    self.browser.implicitly_wait(60)
    self.verificationErrors = []
    
def endCondition(self):
    self.browser.quit()
    self.assertEqual([], self.verificationErrors)

# read data for file xls
def readData(dataFiled,count = sheet0.nrows, rows = sheet0.nrows, cols = sheet0.ncols, index = 1):
    for row_index in range(0,rows):
        for col_index in range(0,cols):
            if sheet0.cell(row_index,col_index).value == dataFiled:
                return sheet0.cell(row_index + index,col_index).value
                    
                    
#def preCondition1(self):
#    self.driver = WebDriver()
#    self.driver.implicitly_wait(30)
#    #self.base_url = "http://localhost/index.php"
#    self.driver.get("http://localhost/index.php")
#    self.verificationErrors = []
        

#def endCondition1(self):
#    self.driver.quit()
#    self.assertEqual([], self.verificationErrors)   
#        
